﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="SoftPhoneToolbar.aspx.cs" Inherits="CRM.Web.AvayaICSoftPhone.SoftPhoneToolbar" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" >
<head id="Head1" runat="server">
    <title></title>
    <link href="<%= base.ResourcesPath + "Style/softphone.css" %>" rel="stylesheet" type="text/css" />
    <link href="<%= base.ResourcesPath + "Style/button.css" %>" rel="stylesheet" type="text/css" />
    <style type="text/css">    
    img { behavior: url(<%= base.ResourcesPath %>Js/iepngfix/iepngfix.htc) }
    </style>
    <object id="softPhoneObject" classid="CLSID:FD54EA28-7A04-4108-8290-F85D2C0F779E" width="0" height="0" ></object>
    <script type="text/javascript" language="javascript" src="Js/SoftPhone.JS"   ></script>
    <script type="text/javascript" language="javascript" src="<%= base.ResourcesPath %>Js/jquery-1.6.2.min.js"  ></script>
    <script type="text/javascript" src="<%= base.ResourcesPath %>Js/iepngfix/iepngfix_tilebg.js"  defer="defer" ></script> 
    <script type="text/javascript"  defer="defer" >
        $(document).ready(function() {
            $(this).bind("mouseup", function() {
                $(this).scrollTop(0);
            });
        });
    </script>
    
    <script language="javascript" type="text/javascript"  defer="defer" >
        var SoftPhoneObject = new ClassSoftPhone(softPhoneObject);
        SoftPhoneObject.IsDebug = true;

        ///电话状态   事件
        //外呼回铃
        SoftPhoneObject.OnInitiating = function(ani, dnis, state, ucid) {           
//            $('#txtTelStatus').html('外呼回铃');
//            $('#txtCaller').html(ani);
//            $('#txtCalled').html(dnis);

            setSoftPhoneStatusHtml('txtTelStatus', '外呼回铃');
            setSoftPhoneStatusHtml('txtCaller', ani);
            setSoftPhoneStatusHtml('txtCalled', dnis);
            
		    SoftPhoneObject.LastStatus = 1;

		    $('#begintime').val(new Date());
            
            $('.PlaceCall').hide();
            $('.PlaceCallDisable').show();

            $('.Answer').hide();
            $('.AnswerDisable').show();

            $('.Hangup').show();
            $('.HangupDisable').hide();

            $('.HoldCall').hide();
            $('.HoldCallDisable').show();

            $('.RetriveCall').hide();
            $('.RetriveCallDisable').show();

            $('.TranCall').hide();
            $('.TranCallDisable').show();

            $('.ConsTranCall').hide();
            $('.ConsTranCallDisable').show();

            $('.Conference').hide();
            $('.ConferenceDisable').show();
            //$('.CollabComplete').hide();
            //$('.CollabCancel').hide();

            $('.TranIVR').hide();
            $('.TranIVRDisable').show();

            $('.Reset').hide();
            $('.ResetDisable').show();
            
            //$('.SetNotReady').hide();
            //$('.SetReady').hide();
            //$('.SetDisReady').show();
        };
        //通话中
        SoftPhoneObject.OnActive = function(ani, dnis, state, ucid) {
            //            $('#txtTelStatus').html('通话中');
            //            $('#txtCaller').html(ani);
            //            $('#txtCalled').html(dnis);

            setSoftPhoneStatusHtml('txtTelStatus', '通话中');
            setSoftPhoneStatusHtml('txtCaller', ani);
            setSoftPhoneStatusHtml('txtCalled', dnis);

            if (ani.length > 4) {
                $('#txtTel').attr('value', ani);
            }
            else {
                $('#txtTel').attr('value', dnis);
            }

            SoftPhoneObject.LastStatus = 3;
            if (SoftPhoneObject.IsActive == 0) {
                $('#begintime').val(new Date());
                SoftPhoneObject.IsActive = 1;
            }
            try {
                if (SoftPhoneObject.IsPopPage) {
                    var outCode = $('#txtOutCode').val();
                    var called = dnis;
                    if (called.indexOf(outCode) == 0) {
                        called = called.substring(1);
                    }
                    this.OnATCallInPopEvent(called, ani, ucid);
                    SoftPhoneObject.IsPopPage = false;
                }
            }
            catch (ex) {

            }

            $('#txtCallID').attr('value', ucid);

            $('.PlaceCall').hide();
            $('.PlaceCallDisable').show();

            $('.Answer').hide();
            $('.AnswerDisable').show();

            $('.Hangup').show();
            $('.HangupDisable').hide();

            $('.HoldCall').show();
            $('.HoldCallDisable').hide();

            $('.RetriveCall').hide();
            $('.RetriveCallDisable').show();

            $('.TranCall').show();
            $('.TranCallDisable').hide();

            $('.ConsTranCall').show();
            $('.ConsTranCallDisable').hide();

            $('.Conference').show();
            $('.ConferenceDisable').hide();
            //$('.CollabComplete').hide();
            //$('.CollabCancel').hide();

            $('.TranIVR').show();
            $('.TranIVRDisable').hide();


            $('.Reset').hide();
            $('.ResetDisable').show();

            //$('.SetNotReady').hide();
            //$('.SetReady').hide();
            //$('.SetDisReady').show();

        };

        //保持呼叫事件
        SoftPhoneObject.OnInActive = function(ani, dnis, state, ucid) {
//            $('#txtTelStatus').html('保持呼叫');
//            $('#txtCaller').html(ani);
//            $('#txtCalled').html(dnis);

            setSoftPhoneStatusHtml('txtTelStatus', '保持呼叫');
            setSoftPhoneStatusHtml('txtCaller', ani);
            setSoftPhoneStatusHtml('txtCalled', dnis);
            
		    SoftPhoneObject.LastStatus = 4;

            //$('#begintime').val(new Date());
            $('.PlaceCall').hide();
            $('.PlaceCallDisable').show();

            $('.Answer').hide();
            $('.AnswerDisable').show();

            $('.Hangup').hide();
            $('.HangupDisable').show();

            $('.HoldCall').hide();
            $('.HoldCallDisable').show();

            $('.RetriveCall').show();
            $('.RetriveCallDisable').hide();

            $('.TranCall').hide();
            $('.TranCallDisable').show();

            $('.ConsTranCall').hide();
            $('.ConsTranCallDisable').show();

            $('.Conference').hide();
            $('.ConferenceDisable').show();
            //$('.CollabComplete').hide();
            //$('.CollabCancel').hide();

            $('.TranIVR').show();
            $('.TranIVRDisable').hide();


            $('.Reset').hide();
            $('.ResetDisable').show();
            //$('.SetNotReady').hide();
            //$('.SetReady').hide();
            //$('.SetDisReady').show();
        };

        //来电振铃事件
        SoftPhoneObject.OnAlerting = function(ani, dnis, state, ucid) {
//            $('#txtTelStatus').html('来电振铃');
//            $('#txtCaller').html(ani);
//            $('#txtCalled').html(dnis);

            setSoftPhoneStatusHtml('txtTelStatus', '来电振铃');
            setSoftPhoneStatusHtml('txtCaller', ani);
            setSoftPhoneStatusHtml('txtCalled', dnis);

		    SoftPhoneObject.LastStatus = 2;
		    $('#begintime').val(new Date());

		    $('.PlaceCall').hide();
		    $('.PlaceCallDisable').show();

		    $('.Answer').show();
		    $('.AnswerDisable').hide();

		    $('.Hangup').show();
		    $('.HangupDisable').hide();

		    $('.HoldCall').hide();
		    $('.HoldCallDisable').show();

		    $('.RetriveCall').hide();
		    $('.RetriveCallDisable').show();

		    $('.TranCall').hide();
		    $('.TranCallDisable').show();
		    
		    $('.ConsTranCall').hide();
		    $('.ConsTranCallDisable').show();

		    $('.Conference').hide();
		    $('.ConferenceDisable').show();
		    //$('.CollabComplete').hide();
		    //$('.CollabCancel').hide();

		    $('.Reset').hide();
		    $('.ResetDisable').show();

		    $('#phone').val(ani);
		    SoftPhoneObject.IsPopPage = false;
            
            //$('.SetNotReady').hide();
            //$('.SetReady').hide();
            //$('.SetDisReady').show();
        };
        
        
        
        //断开
        SoftPhoneObject.OnDisConnected = function(ani, dnis, state, ucid, direction, stime, etime, dtmf, isconnect) {
            //            $('#txtTelStatus').html('空闲'); //
            //            $('#txtSeatStatus').html('事后处理'); 
            //            $('#txtCaller').html('');
            //            $('#txtCalled').html('');
            //            $('#txtTimeLong').html('00:00:15');

            setSoftPhoneStatusHtml('txtTelStatus', '空闲');
            setSoftPhoneStatusHtml('txtSeatStatus', '事后处理');
            setSoftPhoneStatusHtml('txtCaller', '');
            setSoftPhoneStatusHtml('txtCalled', '');
            setSoftPhoneStatusHtml('txtTimeLong', '00:00:15');
            //setSoftPhoneStatusHtml('spanTestMessage', 'direction:' + direction + '--stime:' + stime + '--etime:' + etime);
            SoftPhoneObject.IsActive = 0;
            if (SoftPhoneObject.LastStatus == 2) {
                SoftPhoneObject.ATHangup();
            }

            SoftPhoneObject.LastStatus = 0;

            var date = new Date();
            date.setSeconds(date.getSeconds() + 15);
            $('#begintime').val(date);

            $('.PlaceCall').show();
            $('.PlaceCallDisable').hide();

            $('.Answer').hide();
            $('.AnswerDisable').show();

            $('.Hangup').hide();
            $('.HangupDisable').show();

            $('.HoldCall').hide();
            $('.HoldCallDisable').show();

            $('.RetriveCall').hide();
            $('.RetriveCallDisable').show();

            $('.TranCall').hide();
            $('.TranCallDisable').show();

            $('.ConsTranCall').hide();
            $('.ConsTranCallDisable').show();

            $('.Conference').hide();
            $('.ConferenceDisable').show();
            $('.CollabComplete').hide();
            $('.CollabCancel').hide();

            $('.TranIVR').hide();
            $('.TranIVRDisable').show();

            $('.Reset').show();
            $('.ResetDisable').hide();
            
            try
            {
                writeCallLog(ani, dnis, state, ucid, direction, stime, etime, dtmf, isconnect);
            }
            catch(ex)
            {
            
            }
        };

        SoftPhoneObject.OnNonViable = function(ani, dnis, state, ucid) {
            setSoftPhoneStatusHtml('txtTelStatus', 'NONVIABLE');
            setSoftPhoneStatusHtml('txtCaller', ani);
            setSoftPhoneStatusHtml('txtCalled', dnis);

            $('.Reset').show();
            $('.ResetDisable').hide();
        };
        
        //登录
        SoftPhoneObject.OnLogin = function(eventName, state) {
//            $('#txtSeatStatus').html('登录');
            setSoftPhoneStatusHtml('txtSeatStatus', '登录');
            $('.SetNotReady').hide();
            $('.SetNotReadyDisable').show();
            $('.SetReady').hide();
            $('.SetReadyDisable').show();
            //$('.SetDisReady').hide();
            //SoftPhoneObject.IsReady = 0;
        };

        //示忙
        SoftPhoneObject.OnNotReady = function(eventName, state) {
            //        $('#txtSeatStatus').html('置忙');
            setSoftPhoneStatusHtml('txtSeatStatus', '置忙');
            $('.SetNotReady').hide();
            $('.SetNotReadyDisable').show();
            $('.SetReady').show();
            $('.SetReadyDisable').hide();
            //$('.SetDisReady').hide();
            //SoftPhoneObject.IsReady = 1;
        };

        //示闲
        SoftPhoneObject.OnReady = function(eventName, state) {
            //        $('#txtSeatStatus').html('就绪');
            setSoftPhoneStatusHtml('txtSeatStatus', '就绪');
            $('.SetNotReady').show();
            $('.SetNotReadyDisable').hide();
            $('.SetReady').hide();
            $('.SetReadyDisable').show();
            //$('.SetDisReady').hide();
            //SoftPhoneObject.IsReady = 0;
        };
        
        //未知
        SoftPhoneObject.OnUnknow = function(eventName, state) {
//            $('#txtSeatStatus').html('就绪');
            setSoftPhoneStatusHtml('txtSeatStatus', 'OCCUPIED');
            $('.SetNotReady').show();
            $('.SetNotReadyDisable').hide();
            $('.SetReady').hide();
            $('.SetReadyDisable').show();
            //$('.SetDisReady').show();
            //SoftPhoneObject.IsReady = 0;
            //OCCUPIED
        };
        
        
        
        
        ///来电弹屏		事件
        SoftPhoneObject.OnATCallInPopEvent = function(caller, called, callId, callType) {
            var UserExt = $('#txtUserExt').val().toString();
            PopPage(caller, callId, UserExt, callType, '');
            return false;
        };

        //
        function test(input) {
            alert(input);
        }
        
        //
        function GetCallID() {
            return $('#txtCallID').attr('value');
        }
        
        //
        function GetTelNumber() {
            return $('#txtTel').attr('value');
        }
        
        //呼叫并赋值
        function PlaceCallAndSetValue(tel) {
            $('.phone').val(tel);
            if (tel.length == 0) {
                return false;
            }
            if (tel.length > 4) {
                tel = $('#txtOutCode').val() + $.trim(tel);
            }
            SoftPhoneObject.ATPlaceCall(tel);
            return false;
        }

        //呼叫
        function PlaceCall(tel) {
            if (tel.length == 0) {
                return false;
            }
            if (tel.length > 4) {
                tel = $('#txtOutCode').val() + $.trim(tel);
            }
            SoftPhoneObject.ATPlaceCall(tel);
            return false;
        };
        
        function PlaceCallPopPage(tel) {
            if (tel.length == 0) {
                return false;
            }
            if (tel.length > 4) {
                tel = $('#txtOutCode').val() + $.trim(tel);
                SoftPhoneObject.IsPopPage = true;
            }
            SoftPhoneObject.ATPlaceCall(tel);
            return false;
        };
        
        //转移
        function TranCall(tel) {
            if (tel.length == 0) {
                return false;
            }
            if (tel.length > 4) {
                tel = $('#txtOutCode').val() + $.trim(tel);
            }
            SoftPhoneObject.ATTranCall(tel);
            return false;
        }; 
        //咨询转移
        function Consult(tel) {
            if (tel.length == 0) {
                return false;
            }
            if (tel.length > 4) {
                tel = $('#txtOutCode').val() + $.trim(tel);
            }
            SoftPhoneObject.ATConsult(tel);
            return false;
        };
        
        //会议
        function Meeting(tel) {
            if (tel.length == 0) {
                return false;
            }
            if (tel.length > 4) {
                tel = $('#txtOutCode').val() + $.trim(tel);
            }
            SoftPhoneObject.ATConference(tel);
            return false;
        }
        
        //会议确认
        function ATCollabComplete() {
            SoftPhoneObject.ATCollabComplete();
            return false;
        }
        
        //
        function ATLogout() {
            return SoftPhoneObject.ATLogout();
        }

        //会议取消
        function ATCollabCancel() {
            SoftPhoneObject.ATCollabCancel();
            return false;
        }

        //弹屏
        function PopPage(phone, callid, called, callType, recordCode) {
            var width = 1024;
            var height = 600;
            var left = ($(window).width() - width) / 2;
            var top = 240;
            window.open('../Pop/CallInPopUpPage.aspx?Phone=' + phone + '&called=' + called + '&callid=' + callid + '&calltype=' + callType + '&recordCode=' + recordCode, '来电弹屏' + phone, "height=" + height + ",width=" + width + ",top=" + top + ", left=" + left + ",location=no,menubar=no,toolbar=no,resizable=yes,scrollbars=yes  ");
            return false;
        }

        //写话单
        function writeCallLog(ani, dnis, state, ucid, direction, stime, etime, dtmf, isconnect) {
            var userId = $('#txtUserID').val();
            var userName = $('#txtUserName').val();
            var loginName = $('#txtLoginName').val();
            var seatId = $('#txtSeatID').val();
            var ext = $('#txtUserExt').val();
            var businessDivisionName = $('#txtBusinessDivisionName').val();
            var businessDivisionCode = $('#txtBusinessDivisionCode').val();
            $.ajax({
                type: "POST",   //访问WebService使用Post方式请求
                contentType: "application/json", //WebService 会返回Json类型
                url: "../service/CallLog.asmx/Write", //调用WebService的地址和方法名称组合---WsURL/方法名
                data: "{ani:'" + ani + "',dnis:'" + dnis + "',state:'" + state + "',ucid:'" + ucid + "',direction:'" + direction + "',stime:'" + stime + "',etime:'" + etime + "',dtmf:'" + dtmf + "',isconnect:'" + isconnect + "',userId:'" + userId + "',userName:'" + userName + "',loginName:'" + loginName + "',seatId:'" + seatId + "',ext:'" + ext + "',businessDivisionName:'" + businessDivisionName + "',businessDivisionCode:'" + businessDivisionCode + "'}",
                dataType: 'json',
                success: function(result) {     //回调函数，result，返回值
                    //$('#divMessage').html(result.d);
                    //alert(result.d);
                },
                error: function(x, e) {
                    //alert(x.responseText);
                },
                complete: function(x) {
                    //alert(x.responseText);
                }
            });
        }

        window.onload = function() {
            //登录
            var Url = $('#txtUrl').val().toString();
            var SeatID = $('#txtSeatID').val().toString();
            var UserPWD = $('#txtUserPWD').val().toString();
            var UserExt = $('#txtUserExt').val().toString();
            SoftPhoneObject.ATConnect(Url);
            SoftPhoneObject.ATLogin(SeatID, UserPWD, UserExt);
            //SoftPhoneObject.ATReset();

        };

        window.onunload = function() {
            try {
                SoftPhoneObject.ATLogout();
                SoftPhoneObject.ATDisconnect();
            }
            catch (ex) {

            }
        };

        window.onbeforeunload = function() {
            
            
        };
        
        
        
    </script> 
    <script language="javascript"  event="CallStateChanged(ani,dnis,state,ucid,direction,stime,etime,dtmf,isconnect)" for="softPhoneObject"  >
        SoftPhoneObject.CallStateChanged(ani,dnis,state,ucid,direction,stime,etime,dtmf,isconnect);
    </script>
    <script language="javascript"  event="AgentStateChanged(eventName, state)" for="softPhoneObject"  >
        SoftPhoneObject.AgentStateChanged(eventName, state);
         $('#begintime').append(state + " ");
    </script>
    <script language="javascript"  event="GetString(str)" for="softPhoneObject"  >
        //$('#begintime').val(str);
        //alert(str);
    </script>
    <script type="text/javascript" language="javascript"  >
        var int = self.setInterval("resetTime()", 1000);
        function resetTime() {
//            var status = $('#txtTelStatus').html();
            var status = getSoftPhoneStatusHtml('txtTelStatus');
            if (status == '通话中' || status == '保持呼叫') {
                var now = new Date();
                var beginDate = CreateDate($('#begintime').val());
                var timelong = FormatDate(parseInt((now - beginDate) / 1000));

                //alert(timelong);
//                $('#txtTimeLong').html(timelong);
                setSoftPhoneStatusHtml('txtTimeLong', timelong);
            }
            else if (status == '空闲') {                
                var now = new Date();
                var beginDate = CreateDate($('#begintime').val());
                if (beginDate > now) {
                    var timelong = FormatDate(parseInt((beginDate - now) / 1000));
                    //alert(timelong);
//                    $('#txtTimeLong').html(timelong);
                    setSoftPhoneStatusHtml('txtTimeLong', timelong);
                    
                }
                else {
                    //$('#txtTelStatus').html('空闲');
                }

            }
        }
        function FormatDate(diffTime) {
            var HH = parseInt(diffTime / 3600).toString();
            var mm = parseInt((diffTime % 3600) / 60).toString();
            var ss = ((diffTime % 3600) % 60).toString();
            if (HH.length < 2) {
                HH = "0" + HH.toString();
            }
            if (mm.length < 2) {
                mm = "0" + mm.toString();
            }
            if (ss.length < 2) {
                ss = "0" + ss.toString();
            }

            var retTime = HH + ":" + mm + ":" + ss;
            return retTime;
        }
        function CreateDate(strDate) {
            if (strDate.length == 0) {
                return new Date();
            }
            var s = strDate;
            var d = new Date(Date.parse(s.replace(/-/g, "/")));
            return d;
        }

        function getSoftPhoneStatusHtml(controlName) {
//            var frame = parent.window.frames['frameLeft'];
//            if (frame == null) {
//                return '';
//            }
//            var value = $(frame.document).find('#' + controlName).html();
//            return value;

            return $('#' + controlName).html();    
        }

        function setSoftPhoneStatusHtml(controlName, value) {
//            var frame = parent.window.frames['frameLeft'];
//            if (frame == null) {
//                return;
//            }
//            $(frame.document).find('#' + controlName).html(value);

            $('#' + controlName).html(value);    
        }


        $(document).ready(function() {
            //应答
            $('.Answer').click(function(e) {
                e.preventDefault();
//                SoftPhoneObject.ATAnswer();
                SoftPhoneObject.ATAcceptNumber();

                return false;

            }).hover(function() {
                $(this).attr("src", "<%= base.ResourcesPath %>Images/SoftPhone/button/Answer.gif");
                //$(this).addClass("AnswerHover");
            },
                function() {
                    $(this).attr("src", "<%= base.ResourcesPath %>Images/SoftPhone/button/Answer.gif");
                    //$(this).removeClass("AnswerHover");
                });
            //挂机
            $('.Hangup').bind("click", function(e) {
                e.preventDefault();
                SoftPhoneObject.ATHangup();

                $('.PlaceCall').show();
                $('.PlaceCallDisable').hide();

                $('.Answer').hide();
                $('.AnswerDisable').show();

                $('.Hangup').show();
                $('.HangupDisable').hide();

                //                $('.HoldCall').hide();
                //                $('.HoldCallDisable').show();

                //                $('.RetriveCall').hide();
                //                $('.RetriveCallDisable').show();

                $('.TranCall').hide();
                $('.TranCallDisable').show();

                $('.Conference').hide();
                $('.ConferenceDisable').show();
                $('.CollabComplete').hide();
                $('.CollabCancel').hide();

                $('.TranIVR').hide();
                $('.TranIVRDisable').show();
                return false;

            }).hover(function() {
                $(this).attr("src", "<%= base.ResourcesPath %>Images/SoftPhone/button/HangupHover.jpg");
                //$(this).addClass("HangupHover");
            },
                function() {
                    $(this).attr("src", "<%= base.ResourcesPath %>Images/SoftPhone/button/Hangup.jpg");
                });

            //保持呼叫
            $('.HoldCall').click(function(e) {
                e.preventDefault();
                SoftPhoneObject.ATHoldCall();
                $('.HoldCall').hide();
                $('.HoldCallDisable').show();

                $('.RetriveCall').show();
                $('.RetriveCallDisable').hide();
                return false;

            }).hover(function() {
                $(this).attr("src", "<%= base.ResourcesPath %>Images/SoftPhone/button/HoldCallHover.jpg");
            },
                function() {
                    $(this).attr("src", "<%= base.ResourcesPath %>Images/SoftPhone/button/HoldCall.jpg");
                });

            //恢复呼叫
            $('.RetriveCall').click(function(e) {
                e.preventDefault();
                SoftPhoneObject.ATRetriveCall();
                $('.HoldCall').show();
                $('.HoldCallDisable').hide();

                $('.RetriveCall').hide();
                $('.RetriveCallDisable').show();
                return false;

            }).hover(function() {
                $(this).attr("src", "<%= base.ResourcesPath %>Images/SoftPhone/button/RetriveCallHover.jpg");
            },
                function() {
                    $(this).attr("src", "<%= base.ResourcesPath %>Images/SoftPhone/button/RetriveCall.jpg");
                });

            //示忙
            $('.SetNotReady').click(function(e) {
                e.preventDefault();
                SoftPhoneObject.ATSetBusy();
                return false;

            }).hover(function() {
                $(this).attr("src", "<%= base.ResourcesPath %>Images/SoftPhone/button/SetNotReadyHover.jpg");
            },
                function() {
                    $(this).attr("src", "<%= base.ResourcesPath %>Images/SoftPhone/button/SetNotReady.jpg");
                });

            //示闲
            $('.SetReady').click(function(e) {
                e.preventDefault();
                SoftPhoneObject.ATSetNoBusy();
                return false;

            }).hover(function() {
                $(this).attr("src", "<%= base.ResourcesPath %>Images/SoftPhone/button/SetReadyHover.jpg");
            },
                function() {
                    $(this).attr("src", "<%= base.ResourcesPath %>Images/SoftPhone/button/SetReady.jpg");
                });


            //复位
            $('.Reset').click(function(e) {
                e.preventDefault();
                SoftPhoneObject.ATReset();
                //                var width = 640;
                //                var height = 500;
                //                var left = ($(window).width() - width) / 2;
                //                var top = ($(window).height() - height) / 2;
                //                window.open('PlaceCall.aspx', '呼叫电话', "height=" + height + ",width=" + width + ",top=" + top + ", left=" + left + ",location=no,menubar=no,toolbar=no,resizable=no,scrollbars=yes ");
                return false;
            }).hover(function() {
                $(this).attr("src", "<%= base.ResourcesPath %>Images/SoftPhone/button/ResetHover.jpg");
            },
                function() {
                    $(this).attr("src", "<%= base.ResourcesPath %>Images/SoftPhone/button/Reset.jpg");
                });
            //呼叫
            $('.PlaceCall').click(function(e) {
                e.preventDefault();
                var phone = $('.phone').val();
                PlaceCall(phone);
                //                var width = 640;
                //                var height = 500;
                //                var left = ($(window).width() - width) / 2;
                //                var top = ($(window).height() - height) / 2;
                //                window.open('PlaceCall.aspx', '呼叫电话', "height=" + height + ",width=" + width + ",top=" + top + ", left=" + left + ",location=no,menubar=no,toolbar=no,resizable=no,scrollbars=yes ");
                return false;
            }).hover(function() {
                $(this).attr("src", "<%= base.ResourcesPath %>Images/SoftPhone/button/PlaceCallHover.jpg");
            },
                function() {
                    $(this).attr("src", "<%= base.ResourcesPath %>Images/SoftPhone/button/PlaceCall.jpg");
                });
            //会议
            $('.Conference').click(function(e) {
                e.preventDefault();
                var phone = $('.phone').val();
                Meeting(phone);
                $('.Conference').hide();
                $('.ConferenceDisable').show();
                $('.CollabCancel').show();
                $('.CollabComplete').show();
                //                var width = 640;
                //                var height = 500;
                //                var left = ($(window).width() - width) / 2;
                //                var top = ($(window).height() - height) / 2;
                //                window.open('Meeting.aspx', '会议', "height=" + height + ",width=" + width + ",top=" + top + ", left=" + left + ",location=no,menubar=no,toolbar=no,resizable=no,scrollbars=yes  ");
                return false;

            }).hover(function() {
                $(this).attr("src", "<%= base.ResourcesPath %>Images/SoftPhone/button/ConferenceHover.jpg");
            },
                function() {
                    $(this).attr("src", "<%= base.ResourcesPath %>Images/SoftPhone/button/Conference.jpg");
                });
            //会议确认
            $('.CollabComplete').click(function(e) {
                e.preventDefault();
                ATCollabComplete();

                $('.Conference').show();
                $('.ConferenceDisable').hide();
                $('.CollabCancel').hide();
                $('.CollabComplete').hide();
                //                var width = 640;
                //                var height = 500;
                //                var left = ($(window).width() - width) / 2;
                //                var top = ($(window).height() - height) / 2;
                //                window.open('Meeting.aspx', '会议', "height=" + height + ",width=" + width + ",top=" + top + ", left=" + left + ",location=no,menubar=no,toolbar=no,resizable=no,scrollbars=yes  ");
                return false;
            }).hover(function() {
                $(this).attr("src", "<%= base.ResourcesPath %>Images/SoftPhone/button/OKHover.jpg");
            },
                function() {
                    $(this).attr("src", "<%= base.ResourcesPath %>Images/SoftPhone/button/OK.jpg");
                });

            //会议取消
            $('.CollabCancel').click(function(e) {
                e.preventDefault();
                ATCollabCancel();

                $('.Conference').show();
                $('.ConferenceDisable').hide();
                $('.CollabCancel').hide();
                $('.CollabComplete').hide();
                //                var width = 640;
                //                var height = 500;
                //                var left = ($(window).width() - width) / 2;
                //                var top = ($(window).height() - height) / 2;
                //                window.open('Meeting.aspx', '会议', "height=" + height + ",width=" + width + ",top=" + top + ", left=" + left + ",location=no,menubar=no,toolbar=no,resizable=no,scrollbars=yes  ");
                return false;
            }).hover(function() {
                $(this).attr("src", "<%= base.ResourcesPath %>Images/SoftPhone/button/CancelHover.jpg");
            },
                function() {
                    $(this).attr("src", "<%= base.ResourcesPath %>Images/SoftPhone/button/Cancel.jpg");
                });
            //咨询转移
            $('.ConsTranCall').click(function(e) {
                e.preventDefault();
                var phone = $('.phone').val();
                Consult(phone);
                $('.ConsTranCall').hide();
                $('.ConsTranCallDisable').show();
                $('.TranCallCancel').show();
                $('.TranCallComplete').show();
                return false;
            }).hover(function() {
                $(this).attr("src", "<%= base.ResourcesPath %>Images/SoftPhone/button/ConsTranCallHover.jpg");
            },
                function() {
                    $(this).attr("src", "<%= base.ResourcesPath %>Images/SoftPhone/button/ConsTranCall.jpg");
                });
            //转接确认
            $('.TranCallComplete').click(function(e) {
                e.preventDefault();
                ATCollabComplete();

                $('.ConsTranCall').show();
                $('.ConsTranCallDisable').hide();
                $('.TranCallCancel').hide();
                $('.TranCallComplete').hide();
                return false;
            }).hover(function() {
                $(this).attr("src", "<%= base.ResourcesPath %>Images/SoftPhone/button/OKHover.jpg");
            },
                function() {
                    $(this).attr("src", "<%= base.ResourcesPath %>Images/SoftPhone/button/OK.jpg");
                });

                //转接取消
            $('.TranCallCancel').click(function(e) {
                e.preventDefault();
                ATCollabCancel();

                $('.ConsTranCall').show();
                $('.ConsTranCallDisable').hide();
                $('.TranCallCancel').hide();
                $('.TranCallComplete').hide();
               return false;
            }).hover(function() {
                $(this).attr("src", "<%= base.ResourcesPath %>Images/SoftPhone/button/CancelHover.jpg");
            },
                function() {
                    $(this).attr("src", "<%= base.ResourcesPath %>Images/SoftPhone/button/Cancel.jpg");
                });
            //转IVR
            $('.TranIVR').click(function(e) {
                e.preventDefault();
                //                var value = $('.phone').val();
                //                setSoftPhoneStatusHtml('txtTelStatus', value);
                //                setSoftPhoneStatusHtml('txtSeatStatus', value);
                //                setSoftPhoneStatusHtml('txtCaller', value);
                //                setSoftPhoneStatusHtml('txtCalled', value);
                //                setSoftPhoneStatusHtml('txtTimeLong', value);

                var UserID = $('#txtUserID').val().toString();
                SoftPhoneObject.ATTranCall_toIVR('4107', 1, UserID);
                return false;
            }).hover(function() {
                $(this).attr("src", "<%= base.ResourcesPath %>Images/SoftPhone/button/TranIVRHover.jpg");
            },
                function() {
                    $(this).attr("src", "<%= base.ResourcesPath %>Images/SoftPhone/button/TranIVR.jpg");
                });

            //监听
            $('.JianTing').click(function(e) {
                e.preventDefault();   //*25
                var phone = $('.phone').val();
                SoftPhoneObject.ATPlaceCall('*60' + phone);
                return false;

            }).hover(function() {
                $(this).attr("src", "<%= base.ResourcesPath %>Images/SoftPhone/button/JianTingHover.jpg");
            },
                function() {
                    $(this).attr("src", "<%= base.ResourcesPath %>Images/SoftPhone/button/JianTing.jpg");
                });

            //强插
            $('.QiangCha').click(function(e) {
                e.preventDefault();
                var phone = $('.phone').val();
                SoftPhoneObject.ATPlaceCall('*61' + phone);
                return false;

            }).hover(function() {
                $(this).attr("src", "<%= base.ResourcesPath %>Images/SoftPhone/button/QiangChaHover.jpg");
            },
                function() {
                    $(this).attr("src", "<%= base.ResourcesPath %>Images/SoftPhone/button/QiangCha.jpg");
                });

            //强拆
            $('.QiangCai').click(function(e) {
                e.preventDefault();

                return false;

            }).hover(function() {
                $(this).attr("src", "<%= base.ResourcesPath %>Images/SoftPhone/button/QiangCaiHover.jpg");
            },
                function() {
                    $(this).attr("src", "<%= base.ResourcesPath %>Images/SoftPhone/button/QiangCai.jpg");
                });

            //转移
            $('.TranCall').click(function(e) {
                e.preventDefault();
                var phone = $('.phone').val();
                TranCall(phone);
                //                var width = 640;
                //                var height = 500;
                //                var left = ($(window).width() - width) / 2;
                //                var top = ($(window).height() - height) / 2;
                //                window.open('TranCall.aspx', '转移电话', "height=" + height + ",width=" + width + ",top=" + top + ", left=" + left + ",location=no,menubar=no,toolbar=no,resizable=no,scrollbars=yes  ");
                return false;
            }).hover(function() {
                $(this).attr("src", "<%= base.ResourcesPath %>Images/SoftPhone/button/TranCallHover.jpg");
            },
                function() {
                    $(this).attr("src", "<%= base.ResourcesPath %>Images/SoftPhone/button/TranCall.jpg");
                });
            $('.Test').click(function(e) {
                e.preventDefault();
                var phone = $.trim($('.phone').val().toString());
                var UserExt = $('#txtUserExt').val().toString();
                PopPage(phone, '', UserExt, 1, '');
                return false;
            }).hover(function() {
                $(this).addClass("TestHover");
            },
                function() {
                    $(this).removeClass("TestHover");
                });

            $('.btnLogo').click(function(e) {
                SoftPhoneObject.ATReset();
                return false;
            });

            $('#btnConn').click(function(e) {
                var Url = document.getElementById('txtUrl').value;
                SoftPhoneObject.ATConnect(Url);
                return false;
            });
            $('#btnLogin').click(function(e) {
                SoftPhoneObject.ATLogin(document.getElementById('txtUserID').value, document.getElementById('txtUserPWD').value, document.getElementById('txtUserExt').value);
                return false;
            });
            $('#btnLogout').click(function(e) {
                SoftPhoneObject.ATLogout();
                return false;
            });
        });
    </script>  
</head>
<body>
    <form id="form1" runat="server">
    <table id="tSoftPhoneMain" border="0" cellpadding="0" cellspacing="0">
        <tr>
            <td class="softPhoneLeft">
                <img src="<%= base.ResourcesPath %>Images/SoftPhone/SoftPhone_bg_left.gif" alt="" />
            </td>
            <td class="softPhoneLeftMiddle">
            </td>
            <td class="softPhoneMiddle">
                <div >
                    <input id="phone" class="phone" type="text" /><input id="btnOpenPage" type="button" class="btn_phone_search Test" />
                </div>
            </td>
            <td class="softPhoneRightMiddle">
                <div style="">
                    <img alt="呼叫" title="呼叫" src="<%= base.ResourcesPath %>Images/SoftPhone/button/PlaceCall.jpg"
                        class="imgButton PlaceCall imgWidth" /><img alt="" title="" src="<%= base.ResourcesPath %>Images/SoftPhone/button/PlaceCallDisable.jpg"
                            class="imgButtonDisable PlaceCallDisable imgWidth" style="display: none;" /><img
                                alt="应答" title="应答" src="<%= base.ResourcesPath %>Images/SoftPhone/button/Answer.gif"
                                class="imgButton Answer imgWidth" style="display: none;" /><img alt="" title="" src="<%= base.ResourcesPath %>Images/SoftPhone/button/AnswerDisable.jpg"
                                    class="imgButtonDisable AnswerDisable imgWidth" /><img alt="挂机" title="挂机" src="<%= base.ResourcesPath %>Images/SoftPhone/button/Hangup.jpg"
                                        class="imgButton Hangup imgWidth" style="display: none;" /><img alt="" title="" src="<%= base.ResourcesPath %>Images/SoftPhone/button/HangupDisable.jpg"
                                            class="imgButtonDisable HangupDisable imgWidth" /><img alt="呼叫保持" title="呼叫保持" src="<%= base.ResourcesPath %>Images/SoftPhone/button/HoldCall.jpg"
                                                class="imgButton HoldCall imgWidth" style="display: none;" /><img alt="" title=""
                                                    src="<%= base.ResourcesPath %>Images/SoftPhone/button/HoldCallDisable.jpg" class="imgButtonDisable HoldCallDisable imgWidth" /><img
                                                        alt="恢复呼叫" title="恢复呼叫" src="<%= base.ResourcesPath %>Images/SoftPhone/button/RetriveCall.jpg"
                                                        class="imgButton RetriveCall imgWidth" style="display: none;" /><img alt="" title=""
                                                            src="<%= base.ResourcesPath %>Images/SoftPhone/button/RetriveCallDisable.jpg"
                                                            class="imgButtonDisable RetriveCallDisable imgWidth" /><img alt="示忙" title="示忙" src="<%= base.ResourcesPath %>Images/SoftPhone/button/SetNotReady.jpg"
                                                                class="imgButton SetNotReady imgWidth" /><img alt="" title="" src="<%= base.ResourcesPath %>Images/SoftPhone/button/SetNotReadyDisable.jpg"
                                                                    class="imgButtonDisable SetNotReadyDisable imgWidth" style="display: none;" /><img
                                                                        alt="示闲" title="示闲" src="<%= base.ResourcesPath %>Images/SoftPhone/button/SetReady.jpg"
                                                                        class="imgButton SetReady imgWidth" /><img alt="" title="" src="<%= base.ResourcesPath %>Images/SoftPhone/button/SetReadyDisable.jpg"
                                                                            class="imgButtonDisable SetReadyDisable imgWidth" style="display: none;" /><img alt="转接"
                                                                                title="转接" src="<%= base.ResourcesPath %>Images/SoftPhone/button/TranCall.jpg"
                                                                                class="imgButton TranCall imgWidth" style="display: none;" /><img alt="" title=""
                                                                                    src="<%= base.ResourcesPath %>Images/SoftPhone/button/TranCallDisable.jpg" class="imgButtonDisable TranCallDisable imgWidth" /><img
                                                                                        alt="咨询转接" title="咨询转接" src="<%= base.ResourcesPath %>Images/SoftPhone/button/ConsTranCall.jpg"
                                                                                        class="imgButton ConsTranCall imgWidth" style="display: none;" /><img alt="" title=""
                                                                                            src="<%= base.ResourcesPath %>Images/SoftPhone/button/ConsTranCallDisable.jpg"
                                                                                            class="imgButtonDisable ConsTranCallDisable imgWidth" /><img alt="确认转接" title="确认转接"
                                                                                                src="<%= base.ResourcesPath %>Images/SoftPhone/button/OK.jpg" class="imgButton TranCallComplete imgWidth"
                                                                                                style="display: none;" /><img alt="取消转接" title="取消转接" src="<%= base.ResourcesPath %>Images/SoftPhone/button/Cancel.jpg"
                                                                                                    class="imgButton TranCallCancel imgWidth" style="display: none;" /><img alt="会议"
                                                                                                        title="会议" src="<%= base.ResourcesPath %>Images/SoftPhone/button/Conference.jpg"
                                                                                                        class="imgButton Conference imgWidth" style="display: none;" /><img alt="" title=""
                                                                                                            src="<%= base.ResourcesPath %>Images/SoftPhone/button/ConferenceDisable.jpg"
                                                                                                            class="imgButtonDisable ConferenceDisable imgWidth" /><img alt="确认会议" title="确认会议"
                                                                                                                src="<%= base.ResourcesPath %>Images/SoftPhone/button/OK.png" class="imgButton CollabComplete imgWidth"
                                                                                                                style="display: none;" /><img alt="取消会议" title="取消会议" src="<%= base.ResourcesPath %>Images/SoftPhone/button/Cancel.png"
                                                                                                                    class="imgButton CollabCancel imgWidth" style="display: none;" /><img alt="滿意度" title="滿意度"
                                                                                                                        src="<%= base.ResourcesPath %>Images/SoftPhone/button/TranIVR.jpg" class="imgButton TranIVR imgWidth"
                                                                                                                        style="display: none;" /><img alt="" title="" src="<%= base.ResourcesPath %>Images/SoftPhone/button/TranIVRDisable.jpg"
                                                                                                                            class="imgButtonDisable TranIVRDisable imgWidth" /><img alt="复位" title="复位" src="<%= base.ResourcesPath %>Images/SoftPhone/button/Reset.jpg"
                                                                                                                                class="imgButton Reset imgWidth" /><img alt="" title="" src="<%= base.ResourcesPath %>Images/SoftPhone/button/ResetDisable.jpg"
                                                                                                                                    class="imgButtonDisable ResetDisable imgWidth" style="display: none;" /><img alt="监听"
                                                                                                                                        title="监听" runat="server" id="btnJianTing" src="Images/SoftPhone/button/JianTing.jpg"
                                                                                                                                        class="imgButton JianTing imgWidth" /><img runat="server" id="btnJianTingDisable"
                                                                                                                                            alt="" title="" src="Images/SoftPhone/button/JianTingDisable.jpg"
                                                                                                                                            class="imgButtonDisable JianTingDisable imgWidth" style="display: none;" /><img alt="强插"
                                                                                                                                                title="强插" runat="server" id="btnQiangCha" src="Images/SoftPhone/button/QiangCha.jpg"
                                                                                                                                                class="imgButton QiangCha imgWidth" /><img runat="server" id="btnQiangChaDisable"
                                                                                                                                                    alt="" title="" src="Images/SoftPhone/button/QiangChaDisable.jpg"
                                                                                                                                                    class="imgButtonDisable QiangChaDisable imgWidth" style="display: none;" /><img alt="强拆"
                                                                                                                                                        title="强拆" runat="server" style="display: none;" id="btnQiangCai" src="Images/SoftPhone/button/QiangCai.jpg"
                                                                                                                                                        class="imgButton QiangCai imgWidth" /><img runat="server" id="btnQiangCaiDisable"
                                                                                                                                                            alt="" title="" src="Images/SoftPhone/button/QiangCaiDisable.jpg"
                                                                                                                                                            class="imgButtonDisable QiangCaiDisable imgWidth" style="display: none;" />
                </div>
            </td>
            <td class="softPhoneRight">
                <img src="<%= base.ResourcesPath %>Images/SoftPhone/SoftPhone_bg_right.gif" alt="" />
            </td>
        </tr>
    </table>
    <table id="tSoftPhoneMainB" border="0" cellpadding="0" cellspacing="0">
        <tr>
            <td class="softPhoneMiddleb" >
                <div style="">
                    <img src="<%= base.ResourcesPath %>Images/SoftPhone/tel_logo.png" />
                <span>
                【电话状态：<span id="txtTelStatus" class="StateInfoStyle" style="width: 55px;">空闲</span>】
                【座席状态：<span id="txtSeatStatus" class="StateInfoStyle" style="width: 55px;">&nbsp;</span>】
                【主叫号码：<span id="txtCaller" class="StateInfoStyle" style="width: 80px;">&nbsp;</span>】
                【被叫号码：<span id="txtCalled" class="StateInfoStyle" style="width: 80px;">&nbsp;</span>】
                【通话时长：<span id="txtTimeLong" class="StateInfoStyle">00:00:00</span>】
                <span id="spanTestMessage"></span>
                </span>
                </div>                
    <div style=" display: none; ">
        <div style="width: 100%;">         
            <span style="display: none;">
                <asp:Label id="titleTSRName" runat="server"  >登录姓名：</asp:Label>
                <asp:Label id="lblTSRName" runat="server"  ></asp:Label>&nbsp; &nbsp;
                <asp:Label id="titleExt" runat="server">登录分机：</asp:Label>
                <asp:Label id="lblExt" runat="server" ></asp:Label>&nbsp; &nbsp;
                <asp:Label id="titleLoginTime" runat="server"  >登录时间：</asp:Label>
                <asp:Label id="lblLoginTime" runat="server"  ></asp:Label>
            </span>
            <span >
                <img alt="弹屏" title="弹屏" src=""   />
                <input id="1phone"  type="text"   value="" />
                <input id="begintime" name="begintime"  style="display: none;"  type="text" value='<%= DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") %>' />
                <input id="btnConn" type="button"  value="连接" style="display: none;" /> <input id="btnLogin"  type="button"  value="登录"  style=" display: none;" />
                <input id="btnLogout"  type="button"  value="退出"  style="display: none;"  />
            </span>
        </div>
    </div>
    <div style="display: none;">
        <asp:TextBox Id="txtUrl" runat="server" text=""></asp:TextBox>
        <asp:TextBox ID="txtIP" runat="server" Text="192.168.111.2"></asp:TextBox>
        <asp:TextBox ID="txtPort" runat="server" Text="18000"></asp:TextBox>
        <asp:TextBox ID="txtUserID" runat="server" Text="151"></asp:TextBox>
        <asp:TextBox ID="txtUserPWD" runat="server" Text="1234"></asp:TextBox>
        <asp:TextBox ID="txtUserExt" runat="server" Text="151"></asp:TextBox>
        <asp:TextBox ID="txtSeatID" runat="server" Text="52"></asp:TextBox>
        <asp:TextBox ID="txtCallID" runat="server" Text=""></asp:TextBox>
        <asp:TextBox ID="txtTel" runat="server" Text=""></asp:TextBox>        
        <asp:TextBox ID="txtUserName" runat="server" Text=""></asp:TextBox>
        <asp:TextBox ID="txtLoginName" runat="server" Text=""></asp:TextBox>
        <asp:TextBox ID="txtBusinessDivisionName" runat="server" Text=""></asp:TextBox>
        <asp:TextBox ID="txtBusinessDivisionCode" runat="server" Text=""></asp:TextBox>
        <asp:TextBox ID="txtOutCode" runat="server" Text="0"></asp:TextBox>            
    </div>
            </td>
        </tr>
    </table>
    </form>
</body>
</html>
